package com.jinbo.footmessage;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RatingBar;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jinbo.footmessage.httpretrofit.HttpProtocolFactory;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by jinbo on 2015/8/19.
 */
//不用到这个类
public class ServerStarListViewAdapter extends BaseAdapter {


    static class ViewHolder {
        CircleImageView head;
        TextView name;
        TextView order_number;
        TextView speciality;
        RatingBar star;
    }

    List<MyRandStarBean> order_list;
    private Context context;
    public ServerStarListViewAdapter(Context context, List<MyRandStarBean> data_list){
        this.context=context;
        this.order_list = data_list;

    }

    void setStarList( List<MyRandStarBean> order_list)
    {
        this.order_list=order_list;
    }


    @Override
    public int getCount() {
            // TODO Auto-generated method stub*//*
            if (order_list != null) {
                return order_list.size();
            }
        return 0;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
            if (order_list != null) {
                return order_list.get(position);
            }
        return null;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup arg2)
    {
        final  int num=position;
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.server_inf, null);
            holder = new ViewHolder();
            holder.head=(CircleImageView)convertView.findViewById(R.id.head);
            holder.name=(TextView)convertView.findViewById(R.id.name);
            holder.order_number=(TextView)convertView.findViewById(R.id.order_number);
            holder.speciality=(TextView)convertView.findViewById(R.id.speciality);
            holder.star=(RatingBar)convertView.findViewById(R.id.star);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        Glide.with(context)
                .load(HttpProtocolFactory.HOST_URL_USER+order_list.get(position).getHead())
                        // .placeholder(R.mipmap.ic_launcher)
                        // .crossFade()
                .into(holder.head);
        holder.name.setText(order_list.get(position).getName());
        holder.order_number.setText(order_list.get(position).getOrder_number()+"");
        holder.speciality.setText(order_list.get(position).getSpeciality());
        holder.star.setRating((float)order_list.get(position).getStar());
   //     List<Map<String,Object>> listItems=new ArrayList<>();
   /*     for(int i=0;i<=8;i++) {
            Map<String, Object> listItem = new HashMap<>();
            listItem.put("text", "沐足");
            listItems.add(listItem);
        }*/
  /*      String str="";
        if(position==0) {
         *//*   Map<String, Object> listItem = new HashMap<>();
            listItem.put("text", "沐足");
            listItems.add(listItem);*//*
            str="fasfd";
        }
        else {
      *//*      Map<String, Object> listItem = new HashMap<>();
            listItem.put("text", "沐足fdffadsfasdfdasfasdfasdfadsfadsfadsadssfasfaasfdfdadsffadsff");
            listItems.add(listItem);*//*
            str="fdffadsfasdfdasfasdfasdfadsfadsfadsadssfasfaasfdfdadsffadsf";
        }
        holder.text.setText(str);*/
   /*     listItem= new HashMap<>();
        listItem.put("text", "沐足232");
        listItems.add(listItem);
        listItem= new HashMap<>();
        listItem.put("text", "沐足323");
        listItems.add(listItem);
        listItem= new HashMap<>();
        listItem.put("text", "沐足32");
        listItems.add(listItem);
        listItem= new HashMap<>();
        listItem.put("text", "沐足3233");
        listItems.add(listItem);
*/
      //  SimpleAdapter simpleAdapter=new SimpleAdapter(context,listItems,R.layout.server_cell,new String[]{"text"},new int[]{R.id.server_cell_tv});
     //   holder.grid.setAdapter(simpleAdapter);
       /*     if(cur!=position)
            {
                int tran= context.getResources().getColor(R.color.transparency);
                convertView.setBackgroundColor(tran);
            }*/

        return convertView;
    }
}
